<?php

namespace App\Admin\Controllers\Agent;

use App\model\agent\AgentTousu;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class AgentTousuController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '投诉列表';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new AgentTousu);

        $grid->column('id', __('Id'));
        $grid->column('name', __('姓名'));
        $grid->column('mobile', __('手机号'));
        $grid->column('desc', __('投诉内容'));
        $grid->actions(function(Grid\Displayers\Actions $actions){
            $actions->disableEdit();
        });
        $grid->filter(
            function (Grid\Filter $filter){
                $filter->disableIdFilter();
                $filter->equal('mobile','手机号');
                $filter->equal('name','姓名');
            }
        );
        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(AgentTousu::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('name', __('姓名'));
        $show->field('mobile', __('手机'));
        $show->field('desc', __('内容'));
        $show->field('created_at', __('时间'));



        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new AgentTousu);

        $form->text('name', __('Name'));
        $form->mobile('mobile', __('Mobile'));
        $form->textarea('desc', __('Desc'));

        return $form;
    }
}
